home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / cdef-fjci-fb.hqx / CDEF-FJCI / Source for buttons / arrowButton.bas next >
Encoding:
BASIC Source File  |  1994-09-29  |  1.7 KB  |  67 lines

  1. 'copyright 1994 Robert Schenk
  2. RESOURCES "NewButton.rsc","rsrcRSED","CDEF",10,"arrowButton",0
  3. COMPILE 0,4
  4. DIM ctrlT;8
  5.  
  6. "Entry"
  7. ENTERPROC%(varCode%, the Control&, message%, param&)
  8.   returnValue&=0
  9.   ctrlT;8 = [theControl&]+_contrlRect
  10.   SELECT message%
  11.     CASE _drawCtlMsg
  12.       GOSUB "Draw Control"
  13.     CASE _hitCtlMsg
  14.       GOSUB "User Action"
  15.     CASE _calcCtlMsg
  16.       GOSUB "Calc Control Regions"
  17.   END SELECT
  18.   "Exit"
  19. EXITPROC%=returnValue&
  20. END
  21.  
  22. "Draw Control"
  23. LONG IF PEEK ([theControl&]+_contrlVis)
  24.   ctlTitle$=PSTR$([theControl&]+_contrltitle)
  25.   id=VAL(ctlTitle$)
  26.   selector= PEEK([theControl&]+_contrlHilite)
  27.   SELECT CASE selector
  28.     CASE 255                                      ' grayed
  29.       Hndl&=    FN GETPICTURE(id)
  30.       LONG IF Hndl&
  31.         CALL DRAWPICTURE(Hndl&, ctrlT)
  32.       END IF
  33.     CASE _inDownButton                            ' up arrow, increase
  34.       Hndl&=    FN GETPICTURE(id+2)
  35.       LONG IF Hndl&
  36.         CALL DRAWPICTURE(Hndl&, ctrlT)
  37.       END IF
  38.     CASE _inUpButton                              ' down, decrease
  39.       Hndl&=    FN GETPICTURE(id+3)
  40.       LONG IF Hndl&
  41.         CALL DRAWPICTURE(Hndl&, ctrlT)
  42.       END IF
  43.     CASE ELSE                                     ' regular
  44.       Hndl&=    FN GETPICTURE(id+1)
  45.       LONG IF Hndl&
  46.         CALL DRAWPICTURE(Hndl&, ctrlT)
  47.       END IF
  48.   END SELECT
  49. END IF
  50. RETURN
  51. "User Action"
  52. LONG IF FN PTINRECT(param&, ctrlT)
  53.   ctrlT.bottom=(ctrlT.top+ctrlT.bottom)/2
  54.   LONG IF FN PTINRECT(param&, ctrlT)              ' up
  55.     returnValue&=_inDownButton                    ' we want to increase it when at top
  56.   XELSE
  57.     returnValue&=_inUpButton                      ' we want to decrease when at bottom
  58.   END IF
  59. END IF
  60. RETURN
  61. "Calc Control Regions"
  62. CALL OPENRGN
  63. CALL FRAMERECT(ctrlT)
  64. CALL CLOSERGN(param&)
  65. RETURN
  66.  
  67.